package org.catspaw.cherubim.matcher;

public class JdkRegexUrlMatcher extends JdkRegexStringMatcher implements
		UrlMatcher {

	private boolean	truncate;

	public JdkRegexUrlMatcher() {
	}

	public JdkRegexUrlMatcher(boolean truncate) {
		this.truncate = truncate;
	}

	public JdkRegexUrlMatcher(boolean usePatternCache, boolean truncate) {
		super(usePatternCache);
		this.truncate = truncate;
	}

	@Override
	public boolean match(String pattern, String target) {
		if (isTruncate()) {
			target = UrlUtils.truncateParameters(target);
		}
		if (isConvertUrlToLowercaseBeforeComparison()) {
			target = getLowerCase(target);
		}
		return super.match(pattern, target);
	}

	public boolean isTruncate() {
		return truncate;
	}

	public void setTruncate(boolean truncate) {
		this.truncate = truncate;
	}
}
